﻿package core.ui.controls
{
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;

    public class Button extends Sprite
    {
        public var title:TextField;
        var out:Bitmap;
        var over:Bitmap;
        var bg:Sprite;

        public function Button(param1:String, param2:int)
        {
            this.graphics.beginFill(9474192);
            this.graphics.drawRect(0, 0, param2, 20);
            this.graphics.beginFill(16777215);
            this.graphics.drawRect(1, 1, param2 - 2, 18);
            this.graphics.endFill();
            this.addEventListener(MouseEvent.MOUSE_OVER, this.MouseOver, false, 0, true);
            this.addEventListener(MouseEvent.MOUSE_OUT, this.MouseOut, false, 0, true);
            this.out = new Bitmap(UI.Desaturate(new ButtonFillOn()));
            this.over = new Bitmap(new ButtonFillOn());
            var _loc_3:int = 2;
            this.over.y = 2;
            var _loc_3:* = _loc_3;
            this.over.x = _loc_3;
            var _loc_3:* = _loc_3;
            this.out.y = _loc_3;
            this.out.x = _loc_3;
            var _loc_3:* = param2 - 4;
            this.over.width = param2 - 4;
            this.out.width = _loc_3;
            addChild(this.out);
            this.title = new TextField();
            this.title.y = 1;
            this.title.defaultTextFormat = new TextFormat("Arial, Helvetica, San-serif", AppState.TextSize, 0, false, false, false, null, null, "center");
            this.title.height = 18;
            this.title.width = param2;
            this.title.multiline = false;
            this.title.selectable = false;
            this.title.text = U.RM(param1);
            addChild(this.title);
            return;
        }// end function

        private function MouseOver(event:MouseEvent) : void
        {
            this.removeChildAt(0);
            this.addChildAt(this.over, 0);
            return;
        }// end function

        private function MouseOut(event:MouseEvent) : void
        {
            this.removeChildAt(0);
            this.addChildAt(this.out, 0);
            return;
        }// end function

    }
}
